# Copyright (c) 2025 Shenzhen Kaihong Digital Industry Development Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.16)
project(rerun-tools-cpp LANGUAGES C ASM CXX)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if("${CMAKE_BUILD_TYPE}" STREQUAL "")
    set(CMAKE_BUILD_TYPE Release)    
endif()

set(CXX_STANDARD 17)

# eigen
find_package(Eigen3 REQUIRED)

# pcl
find_package(PCL REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

# rerun sdk
include(FetchContent)
if("${RERUN_SDK_PATH}" STREQUAL "")
FetchContent_Declare(rerun_sdk URL
    https://github.com/rerun-io/rerun/releases/download/0.15.1/rerun_cpp_sdk.zip
    URL_HASH SHA256=b849d760e30ee39144430f6d56f08ec1718c5595f83683fbe4c546d703770bfe)
else()
    FetchContent_Declare(rerun_sdk
    SOURCE_DIR ${RERUN_SDK_PATH})
endif()
FetchContent_MakeAvailable(rerun_sdk)

# librerun_tools_cpp
include_directories(include)
aux_source_directory(lib SRC_LIB)
add_library(rerun_tools_cpp ${SRC_LIB})
target_link_libraries(rerun_tools_cpp PRIVATE rerun_sdk ${PCL_LIBRARIES})
